﻿<Page x:Class="Probel.Ldoc.Views.Pages.SearchView"
      
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:t="clr-namespace:Probel.Ldoc.Views.Properties"
      xmlns:ctrl="clr-namespace:Probel.Ldoc.Views.Controls"
      
      mc:Ignorable="d" 
      d:DesignHeight="768" 
      d:DesignWidth="1024"
      
      Loaded="Page_Loaded">
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Themes/Generic.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Page.Resources>
    <HeaderedContentControl Header="{x:Static t:Messages.Header_Search}">
        <TabControl>
            <TabItem Header="{x:Static t:Messages.Header_Search}">
                <DockPanel>
                    <DockPanel DockPanel.Dock="Top"
                       LastChildFill="False"
                       Height="30">
                        <TextBox x:Name="focused"
                                 DockPanel.Dock="Left"
                                 Text="{Binding Criterion, UpdateSourceTrigger=PropertyChanged}"
                                 Margin="5,5,0,5"
                                 Width="250">
                            <TextBox.InputBindings>
                                <KeyBinding Key="Enter"
                                            Command="{Binding SimpleSearchCommand}"/>
                            </TextBox.InputBindings>
                        </TextBox>
                        <Button DockPanel.Dock="Left"
                                Background="{x:Null}" 
                                BorderBrush="{x:Null}"
                                Command="{Binding SimpleSearchCommand}">
                            <Image Source="/Probel.Ldoc.Views;component/Images/Magnifier.png" 
                                   Stretch="None"/>
                        </Button>
                    </DockPanel>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="350"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <DockPanel>

                            <TextBlock DockPanel.Dock="Bottom"
                                       HorizontalAlignment="Right">
                                <Run Text="{Binding SearchCount}"/>
                                <Run Text="{x:Static t:Messages.Lbl_SearchCount}"/>
                            </TextBlock>
                            <ListView x:Name="resultList" 
                                      ItemsSource="{Binding SearchResult}"
                                      HorizontalContentAlignment="Stretch"
                                      VerticalContentAlignment="Stretch"
                                      SelectedItem="{Binding SelectedPatient}" 
                                      MouseLeftButtonUp="ResultList_Click">
                                <ListView.ItemTemplate>
                                    <DataTemplate>
                                        <ctrl:PatientCardView/>
                                    </DataTemplate>
                                </ListView.ItemTemplate>
                            </ListView>
                        </DockPanel>
                        <ctrl:PatientView Grid.Column="1"
                                          DataContext="{Binding ExpandedPatient}"/>
                    </Grid>
                </DockPanel>
            </TabItem>
            <TabItem Header="Advanced search"/>
        </TabControl>
    </HeaderedContentControl>
</Page>


